package util

import (
	"crypto/sha256"
	"encoding/hex"
)

// SignSha256 sha256 签名计算
func SignSha256(sign string) (string, error) {
	h := sha256.New()
	_, err := h.Write([]byte(sign))
	if err != nil {
		return "", err
	}
	return hex.EncodeToString(h.Sum(nil)), nil
}

// Sha256Hash 消息hash
func Sha256Hash(msg []byte) (string, error) {
	h := sha256.New()
	_, err := h.Write(msg)
	if err != nil {
		return "", err
	}
	return hex.EncodeToString(h.Sum(nil)), nil
}
